package vip.xumy.admin.sys.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import vip.xumy.admin.sys.pojo.SysConfig;

/**
 * @author:mengyxu
 * @date:2019年12月6日
 */

@Mapper
public interface IConfigMapper {

	@Select({ "SELECT cfg_value FROM sys_config WHERE cfg_key = #{cfgKey} AND cfg_status != 'I'" })
	public String queryValueByKey(String cfgKey);

	@Select({ "<script>", "SELECT * FROM sys_config ", "<where>",
			"<if test='cfgKey != null'> AND cfg_key = #{cfgKey} </if>",
			"<if test='cfgStatus != null'> AND cfg_status = #{cfgStatus} </if>",
			"<if test='cfgName != null'> AND cfg_name like CONCAT('%',#{cfgName},'%') </if>", "</where>",
			"ORDER BY update_time DESC", "</script>" })
	public List<SysConfig> queryByExample(SysConfig example);

	@Update({ "UPDATE sys_config SET cfg_name = #{cfgName}, cfg_value = #{cfgValue}, cfg_desc = #{cfgDesc}, ",
			"cfg_status = #{cfgStatus}, update_time = NOW(), update_user = #{updateUser} WHERE cfg_key = #{cfgKey}" })
	public void update(SysConfig sysConfig);

}
